package cn.dankal.flyaudio.adapter;

import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import cn.dankal.basiclib.base.recyclerview.BaseRecyclerViewAdapter;
import cn.dankal.basiclib.base.recyclerview.BaseRecyclerViewHolder;
import cn.dankal.basiclib.pojo.ProductDetailAttrEntity;
import cn.dankal.basiclib.pojo.ProductDetailItemEntity;
import cn.dankal.basiclib.util.ActivityUtils;
import cn.dankal.business.pojo.OrderBean;
import cn.dankal.flyaudio.R;
import cn.dankal.flyaudio.personal.MyOrderDetailActivity;

public class ProductsAdapter extends BaseRecyclerViewAdapter<ProductDetailItemEntity> {
    @Override
    protected int getLayoutResId(int viewType) {
        return R.layout.item_order_products;
    }

    @Override
    protected BaseRecyclerViewHolder getViewHolder(ViewGroup parent, View rootView, int viewType) {
        return new ViewHolder(rootView);
    }

    class ViewHolder extends BaseRecyclerViewHolder<ProductDetailItemEntity> {

        public ViewHolder(View itemView) {
            super(itemView);
        }

        @Override
        public void onBindData(ProductDetailItemEntity data, int position) {
            setImageUrl(R.id.iv_order_img, data.getImgUrl());
            setText(R.id.tv_name, data.getProductName());
            setText(R.id.tv_amount, "¥" + data.getDiscountedPrice());
            setText(R.id.tv_discount_price, "¥" + data.getOriginPrice());
            setTextDeleteStyle(R.id.tv_discount_price);
            setText(R.id.tv_count, "X  " + data.getItemCount());
            StringBuilder sb = new StringBuilder();
            List<ProductDetailAttrEntity> attrEntities = data.getAttrList();
            if (attrEntities == null) {
                return;
            }
            for (ProductDetailAttrEntity attrEntity : attrEntities) {
                sb.append(attrEntity.getAttrValue());
                sb.append("  ");
            }
            setText(R.id.tv_sku, sb.toString());

        }
    }
}
